package com.winsomely.leecode;

/**
 * 字符串中的单词数
 * 
 * @author liujiawei
 *
 */
public class ArrangeCoins {

	// ((1 + h) * h) = 2n;
	// h^2 + h = 20
	public int arrangeCoins(int n) {
		return (int) (Math.sqrt((2 * (double) n) + 0.25) - 0.5);
	}

	public static void main(String[] args) {
		ArrangeCoins t = new ArrangeCoins();
		int n = 1804289383;
		System.out.println(t.arrangeCoins(n));
	}

}
